package com.zjt.smart.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.zjt.smart.mvp.model.BaiduImageListBean;
import com.zjt.smart.ui.adapter.base.BaseAdapter;
import com.zjt.smart.ui.adapter.holder.BaiduImageListHolder;
import com.zjt.smart.util.ImageUtil;

/**
 * @author zhengjianting
 * @time 2017/11/3 0003 下午 2:03
 */

public class BaiduImageListAdapter extends BaseAdapter<BaiduImageListHolder, BaiduImageListBean.DataBean> {

    public BaiduImageListAdapter(Context mContext) {
        super(mContext);
    }

    @Override
    protected void onBindItemDataToView(BaiduImageListHolder holder, BaiduImageListBean.DataBean itemData, int position) {
        if (TextUtils.isEmpty(itemData.getImage_url())) return;
        ImageUtil.load(mContext, holder.getIvImage(), itemData.getImage_url());
        holder.getTvTitle().setText(itemData.getAbs() + itemData.getDesc());
    }

    @Override
    protected BaiduImageListHolder onCreateHolder(ViewGroup parent, int viewType) {
        return new BaiduImageListHolder(LayoutInflater.from(getContext()), parent);
    }
}
